<%@ page language="java" contentType="application/vnd.ms-excel; name='report_4';charset=utf-8"
    pageEncoding="UTF-8" import="com.java.service.*,java.util.*,com.java.model.UserSession,com.java.util.*,java.text.SimpleDateFormat"%>
<%
response.setHeader("Content-Disposition", "inline; filename=report_4.xls"); // 파일 이름 지정
response.setHeader("Content-Description", "JSP Generated Data");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Excel Download</title>
</head>
<%

UserSession usersession = (UserSession)session.getAttribute("user");
//String ent_id 			= (String)session.getAttribute("ent_id");

String connGroup 	= "";
String user_id 		= "";
if(usersession!=null){
	connGroup 	= CmmUtil.nvl(usersession.getConnGroup(),"0");
	user_id 	= CmmUtil.nvl(usersession.getUser_id(),"");
}

System.out.println("connGroup======>"+connGroup);
System.out.println("user_id======>"+user_id);

String keyword_gb 	= CmmUtil.nvl(request.getParameter("search_gb"),"");
String keyword 		= CmmUtil.nvl(request.getParameter("search_word"),"");
String line_number	= CmmUtil.nvl(request.getParameter("line_number"),"10");
String search_date = CmmUtil.nvl(request.getParameter("search_date"),"");

String start_dt = CmmUtil.nvl(request.getParameter("start_dt"),"");
String close_dt = CmmUtil.nvl(request.getParameter("close_dt"),"");

System.out.println("keyword ======> " + keyword);

java.util.Date date = new java.util.Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");     
String today = formatter.format(date); 


if (search_date == null || search_date.equals(""))
	search_date = "";

//페이징 처리 Start
	//페이지 표시정보 받기 혹은 검색입력창
	String curr_page = request.getParameter("curr_page");
	if (curr_page == null || curr_page.equals(""))
		curr_page = "1";
	String one_page = request.getParameter("one_page");
	if (one_page == null || one_page.equals(""))
		one_page = "10";
	String one_group = request.getParameter("one_group");
	if (one_group == null || one_group.equals(""))
		one_group = "10";
	
	String total_count = CmmUtil.nvl(request.getParameter("total_count"),"0");
	
	//페이징 처리 End
	
	
	
	HashMap map_cnt = new HashMap();
	HashMap map1_cnt = null;
	HashMap map1_cnt2 = null;
	ArrayList list_cnt = new ArrayList();	
	CommonDaoService commonservice_cnt = new CommonDaoService("Com0204lp01Dao_cnt");
	map_cnt.put("connGroup",connGroup);
	map_cnt.put("user_id",user_id);	
	map_cnt.put("start_dt",start_dt);	
	map_cnt.put("close_dt",close_dt);		
	list_cnt = (ArrayList)commonservice_cnt.commonDaoMethod(map_cnt);	
	System.out.println(list_cnt);
	
	HashMap map = new HashMap();
	HashMap map1 = null;
	ArrayList list = new ArrayList();
	CommonDaoService commonservice = new CommonDaoService("Com0204lp01Dao");
	map.put("connGroup",connGroup);
	map.put("user_id",user_id);		
	map.put("keyword_gb",keyword_gb);
	map.put("keyword",keyword);	
	map.put("start_dt",start_dt);	
	map.put("close_dt",close_dt);
	map.put("page_row",total_count);
	map.put("total_row","0");
	map.put("page_no","0");
	
	list = (ArrayList)commonservice.commonDaoMethod(map);
	
	System.out.println(list);
	
	if(list != null){
		if(list.size() > 0){
			total_count = (String)((HashMap)list.get(0)).get("total_row");
			System.out.println("total_count " + total_count);
		}
	}
	
	String app_str="";
	
	String edu_cnt = "0";
	String poi_cnt = "0";


	String mis_conn_dt = "0";
	String poorly_cnt = "0";

	String recommend_ave_rate = "0";
	String final_prog_ave_rate = "0";
	
	for(int i=0; i<list_cnt.size(); i++){
		map1_cnt 			= (HashMap)list_cnt.get(i);  
		
		edu_cnt =  CmmUtil.nvl((String)map1_cnt.get("s_cate_cnt"),"0");
		poi_cnt = CmmUtil.nvl((String)map1_cnt.get("s_poi_cd_cnt"),"0");
		
		recommend_ave_rate = CmmUtil.nvl((String)map1_cnt.get("recommend_rate"),"0");
		final_prog_ave_rate = CmmUtil.nvl((String)map1_cnt.get("final_prog_rate"),"0");
		
		mis_conn_dt = CmmUtil.nvl((String)map1_cnt.get("conn_mis"),"0");
		poorly_cnt = CmmUtil.nvl((String)map1_cnt.get("stu_mis"),"0");	
	}
	
%>

<body>
<form name="excel_frm">
<b></b>
</BR>
</BR>

<table width="760" border="1" cellpadding="2" cellspacing="0" bordercolor="C0C0C0" bordercolordark="#FFFFFF" frame=below >
                  <tr>
                    <td bgcolor="#D3EBD7">학습인원</td>
                    <td><%=edu_cnt %>명</td>
                    <td>&nbsp;</td>
                    <td bgcolor="#D3EBD7">수강과정</td>
                    <td><%=poi_cnt %> 과정</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td bgcolor="#D3EBD7">평균 진도 율</td>
                    <td><%=final_prog_ave_rate%>%</td>
                    <td><!-- <a href="#"><img src="/images/hrd_main_BTN9.gif" alt="" border="0"/></a> --></td>
                    <td bgcolor="#D3EBD7">권장 진도 율</td>
                    <td><%=recommend_ave_rate%>%</td>
                    <td><!-- <a href="#"><img src="/images/hrd_main_BTN9.gif" alt="" border="0"/></a>--></td>
                  </tr>
                  <tr>
                    <td bgcolor="#D3EBD7">진도 부진 자</td>
                    <td><%=poorly_cnt %>명</td>
                    <td><!-- <a href="#"><img src="/images/hrd_main_BTN9.gif" alt="" border="0"/></a>--></td>
                    <td bgcolor="#D3EBD7">미 접속 자</td>
                    <td><%=mis_conn_dt %>명</td>
                    <td><!-- <a href="#"><img src="/images/hrd_main_BTN9.gif" alt="" border="0"/></a>--></td>
                  </tr>
</table>   
<table><tr><td></td></tr><tr><td></td></tr></table>
<table width="760" border="1" cellpadding="2" cellspacing="0" bordercolor="C0C0C0" bordercolordark="#FFFFFF" frame=below >
                  <tr>
                    <td bgcolor="#D3EBD7">번호</td>
                    <td bgcolor="#D3EBD7">이름</td>
                    <td bgcolor="#D3EBD7">학습과정명</td>
                    <td bgcolor="#D3EBD7">1주차</td>
					 <td bgcolor="#D3EBD7">2주차</td>
					 <td bgcolor="#D3EBD7">3주차</td>
					 <td bgcolor="#D3EBD7">4주차</td>
					 <td bgcolor="#D3EBD7">5주차</td>
					 <td bgcolor="#D3EBD7">6주차</td>
					 <td bgcolor="#D3EBD7">7주차</td>
					 <td bgcolor="#D3EBD7">8주차</td>
					 <td bgcolor="#D3EBD7">9주차</td>
					 <td bgcolor="#D3EBD7">10주차</td> 
                    <td bgcolor="#D3EBD7">과제제출여부</td>
                    <td bgcolor="#D3EBD7">시험응시여부</td>
                    
                  </tr>
			<%for(int i=0; i<list.size(); i++){
            	map1 			= (HashMap)list.get(i);       	
            	
            	
			%>
                  <tr>
                    <td><%=map1.get("rownum") %></td>
                    <td><%=map1.get("login_nm") %></td>
                    <td><%=map1.get("poi_nm2") %></td>
                    <td><%=map1.get("t1") %></td>
					<td><%=map1.get("t2") %></td>
					<td><%=map1.get("t3") %></td>
					<td><%=map1.get("t4") %></td>
					<td><%=map1.get("t5") %></td>
					<td><%=map1.get("t6") %></td>
					<td><%=map1.get("t7") %></td>
					<td><%=map1.get("t8") %></td>
					<td><%=map1.get("t9") %></td>
					<td><%=map1.get("t10") %></td>
                    <td><%=CmmUtil.nvl((String)map1.get("repo_yn") ,"") %></td>
					<td><%=CmmUtil.nvl((String)map1.get("test_yn") ,"") %></td>                    
                  </tr>
			<%} %>
                  
</table>   


</form>

</body>
</html>
